package edu.predatorwars.server.webservices;

import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;

import com.sun.jersey.spi.resource.Singleton;

import edu.predatorwars.server.host.GameHostImpl;
import edu.predatorwars.server.host.GameHostInterface;
import edu.predatorwars.shared.models.*;

@Singleton
@Path("predatorwars")
@Consumes ("application/json")
@Produces ("application/json")
public class HostResource implements GameHostInterface {

	private GameHostInterface host = new GameHostImpl();
	
	@Path("/creategame")
	@POST
	public Boolean createGame(Player joiningPlayer) {
		return host.createGame(joiningPlayer);
	}

	@Path("/joingame")
	@POST
	public Boolean joinGame(PlayerGamePayload payload) {
		host.joinGame(payload);
		return false;
	}

	@Path("/quitgame")
	@POST
	public Boolean quitGame(PlayerGamePayload payload) {
		return host.quitGame(payload);
	}

	@Path("/selectcharacter")
	@POST
	public Boolean selectCharacter(SelectCharacterPayload payload) {	
		return host.selectCharacter(payload);
	}

	@Path("/move")
	@POST
	public Boolean move(MovementPayload payload) {
		return host.move(payload);
	}

	@Path("/refreshlist")
	@GET
	public GameListPayload refreshGameList() {
		return host.refreshGameList();
	}
	
	@Path("/ip")
	@GET
	public String getIP(@Context HttpServletRequest request) {
		return request.getRemoteAddr();
	}
}
